package pl.edu.agh.winmon.hibernate;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * Represents logical's processor load.
 */
@Entity
@Table(name = "`" + CpuLoad.TABLE_NAME + "`")
public class CpuLoad implements Serializable {

	@Transient
	private static final long serialVersionUID = -3263943171643640151L;

	/**
	 * Table name.
	 */
	@Transient
	public static final String TABLE_NAME = "cpu_load"; //$NON-NLS-1$

	/**
	 * Hibernate's annotation property: id.
	 */
	@Transient
	public static final String PROP_ID = "id"; //$NON-NLS-1$

	/**
	 * Database column name: id;
	 */
	@Transient
	public static final String DB_ID = PROP_ID;

	/**
	 * Hibernate's annotation property: turn id.
	 */
	@Transient
	public static final String PROP_TURN = "turn"; //$NON-NLS-1$

	/**
	 * Database column name: turn id;
	 */
	@Transient
	public static final String DB_TURN = "turn_id"; //$NON-NLS-1$

	/**
	 * Hibernate's annotation property: CPU load.
	 */
	@Transient
	public static final String PROP_CPU_LOAD = "cpuLoad"; //$NON-NLS-1$

	/**
	 * Database column name: CPU load;
	 */
	@Transient
	public static final String DB_CPU_LOAD = "cpu_load"; //$NON-NLS-1$

	/**
	 * Hibernate's annotation property: CPU number.
	 */
	@Transient
	public static final String PROP_CPU_NUMBER = "cpuNumber"; //$NON-NLS-1$

	/**
	 * Database column name: CPU number;
	 */
	@Transient
	public static final String DB_CPU_NUMBER = "cpu_number"; //$NON-NLS-1$

	/**
	 * Id of the turn.
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = DB_ID)
	private Long id;

	/**
	 * Turn of collected data.
	 */
	@ManyToOne
	@JoinColumn(name = DB_TURN)
	private Turn turn;

	/**
	 * Load of the CPU.
	 */
	@Column(name = DB_CPU_LOAD)
	private Double cpuLoad;

	/**
	 * Number of logical CPU.
	 */
	@Column(name = DB_CPU_NUMBER)
	private Integer cpuNumber;

	/**
	 * Returns id.
	 * 
	 * @return id.
	 */
	public Long getId() {
		return id;
	}

	/**
	 * Sets id.
	 * 
	 * @param id
	 *            id.
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * Returns turn of collected data.
	 * 
	 * @return Turn of collected data.
	 */
	public Turn getTurn() {
		return turn;
	}

	/**
	 * Set turn of collected data.
	 * 
	 * @param turn
	 *            Turn of collected data.
	 */
	public void setTurn(Turn turn) {
		this.turn = turn;
	}

	/**
	 * Returns load of the CPU.
	 * 
	 * @return Load of the CPU.
	 */
	public Double getCpuLoad() {
		return cpuLoad;
	}

	/**
	 * Sets load of the CPU.
	 * 
	 * @param cpuLoad
	 *            Load of the CPU.
	 */
	public void setCpuLoad(Double cpuLoad) {
		this.cpuLoad = cpuLoad;
	}

	/**
	 * Returns number of logical CPU.
	 * 
	 * @return Number of logical CPU.
	 */
	public Integer getCpuNumber() {
		return cpuNumber;
	}

	/**
	 * Sets number of logical CPU.
	 * 
	 * @param cpuNumber
	 *            Number of logical CPU.
	 */
	public void setCpuNumber(Integer cpuNumber) {
		this.cpuNumber = cpuNumber;
	}
}
